package com.clinic.entity.db;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.clinic.entity.type.UserType;

@Entity
@Table(name = User.TABLE)
@Inheritance(strategy = InheritanceType.JOINED)
public class User implements Serializable {
	
	private static final long serialVersionUID = 4056883180890702949L;
	
	public static final String TABLE = "user";
	
	public static final class Columns {
		public static final String USER_ID = "userId";
		public static final String NAME = "name";
		public static final String TYPE = "type";
		public static final String ADMIN = "admin";
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = Columns.USER_ID)
	private long userId;
	
	@Column(name = Columns.NAME)
	private String name;
	
	@Enumerated(EnumType.STRING)
	@Column(name = Columns.TYPE)
	private UserType type;
	
	@Column(name = Columns.ADMIN)
	private boolean admin;
	
	@OneToOne(mappedBy="user", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
	private UserContact contact;
	
	@OneToOne(mappedBy="user", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
	private UserLogin login;
	
	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public UserType getType() {
		return type;
	}

	public void setType(UserType type) {
		this.type = type;
	}
	
	public boolean isAdmin() {
		return admin;
	}

	public void setAdmin(boolean admin) {
		this.admin = admin;
	}

	public UserContact getContact() {
		return contact;
	}
	
	public void setContact(UserContact contact) {
		this.contact = contact;
	}

	public UserLogin getLogin() {
		return login;
	}

	public void setLogin(UserLogin login) {
		this.login = login;
	}
	
}
